package com.brillilab.message.core.config;

import com.brillilab.common.redis.RedisCache;
import com.brillilab.message.core.SocketMessageSender;
import com.brillilab.service.core.lab.ILabDeviceService;
import com.brillilab.service.core.message.IMessageService;
import com.brillilab.service.logic.user.UsersLogic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

/**
 * WebSocket配置
 * @author lj
 *
 */
@Configuration    
public class WebSocketConfig {   
	/**
	 * 如果不是spring boot项目，那就不需要配置，因为如果在tomcat中运行的话，
	 * tomcat会扫描带有@ServerEndpoint的注解成为websocket，而spring boot项目中需要由这个bean来提供注册管理。
	 */
    @Bean    
    public ServerEndpointExporter serverEndpointExporter(){    
        return new ServerEndpointExporter();    
    }

    @Autowired
    public void setMessageService(IMessageService messageService){
        SocketMessageSender.messageService = messageService;
    }

    @Autowired
    public void setRedisCache(RedisCache redisCache){
        SocketMessageSender.redisCache = redisCache;
    }
} 
